package com.tudouji.project.d3.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.github.pagehelper.PageHelper;
import com.tudouji.common.utils.DateUtils;
import com.tudouji.common.utils.StringUtils;
import com.tudouji.common.utils.sql.SqlUtil;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.framework.web.page.PageDomain;
import com.tudouji.framework.web.page.TableSupport;
import com.tudouji.project.d3.domain.D3Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.tudouji.project.d3.mapper.D3ToSellformMapper;
import com.tudouji.project.d3.domain.D3ToSellform;
import com.tudouji.project.d3.service.ID3ToSellformService;

/**
 * 平台订单中间Service业务层处理
 * 
 * @author tudouji
 * @date 2023-04-10
 */
@Service
public class D3ToSellformServiceImpl implements ID3ToSellformService 
{
    @Autowired
    private D3ToSellformMapper d3ToSellformMapper;

    /**
     * 查询平台订单中间
     * 
     * @param id 平台订单中间ID
     * @return 平台订单中间
     */
    @Override
    public D3ToSellform selectD3ToSellformById(Long id)
    {
        return d3ToSellformMapper.selectD3ToSellformById(id);
    }

    /**
     * 设置请求分页数据
     */
    protected void startPage()
    {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
        {
            String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
            PageHelper.startPage(pageNum, pageSize, orderBy);
        }
    }

    /**
     * 查询平台订单中间列表
     * 
     * @param d3ToSellform 平台订单中间
     * @return 平台订单中间
     */
    @Override
    public List<D3ToSellform> listPc(D3ToSellform d3ToSellform)
    {
        /*SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

        try {
            if (StringUtils.isNotEmpty(d3ToSellform.getBeginTime())) {
                Date date = simpleDateFormat.parse(d3ToSellform.getBeginTime());
                Long l = date.getTime();
                String s = String.valueOf(l);
                d3ToSellform.setBeginTime(s);
            }
            if (StringUtils.isNotEmpty(d3ToSellform.getEndTime())) {
                Date date1 = simpleDateFormat.parse(d3ToSellform.getEndTime());
                Long l1 = date1.getTime();
                String s1 = String.valueOf(l1);
                d3ToSellform.setEndTime(s1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }*/
        List<D3ToSellform> d3ToSellforms = d3ToSellformMapper.listPc(d3ToSellform);
        return d3ToSellforms;
    }
    @Override
    public List<D3ToSellform> selectD3ToSellformList(D3ToSellform d3ToSellform)
    {
        return d3ToSellformMapper.selectD3ToSellformList(d3ToSellform);
    }

    /**
     * 修改平台订单中间
     *
     * @param d3ToSellform 平台订单中间
     * @return 结果
     */
    @Override
    public int updateD3ToSellform(D3ToSellform d3ToSellform)
    {
        d3ToSellform.setUpdateTime(DateUtils.getNowDate());
        return d3ToSellformMapper.updateD3ToSellform(d3ToSellform);
    }

    @Override
    public int insertD3ToSellform(D3ToSellform d3ToSellform)
    {
        d3ToSellform.setCreateTime(DateUtils.getNowDate());
        return d3ToSellformMapper.insertD3ToSellform(d3ToSellform);
    }

    /**
     * 批量删除平台订单中间
     * 
     * @param ids 需要删除的平台订单中间ID
     * @return 结果
     */
    @Override
    public int deleteD3ToSellformByIds(Long[] ids)
    {
        return d3ToSellformMapper.deleteD3ToSellformByIds(ids);
    }

    /**
     * 删除平台订单中间信息
     * 
     * @param id 平台订单中间ID
     * @return 结果
     */
    @Override
    public int deleteD3ToSellformById(Long id)
    {
        return d3ToSellformMapper.deleteD3ToSellformById(id);
    }
}
